classdef VoipPacketsGenerator < ClockHandler
    properties
        src_to_dest_cbr_packets_generator;
        dest_to_src_cbr_packets_generator;
    end
    
    methods
        function obj = VoipPacketsGenerator(source_node, dest_node, packet_size_in_Kbytes, data_rate_in_Kbps)
            src_to_dest_packet_template = PacketsManager.instance().create_template_packet(source_node, dest_node, packet_size_in_Kbytes);
            obj.src_to_dest_cbr_packets_generator = CBRPacketGenerator(src_to_dest_packet_template, data_rate_in_Kbps);
            
            dest_to_src_packet_template = PacketsManager.instance().create_template_packet(dest_node, source_node, packet_size_in_Kbytes);
            obj.dest_to_src_cbr_packets_generator = CBRPacketGenerator(dest_to_src_packet_template, data_rate_in_Kbps);
            
            % register on clock tick
            ck = ClockSingleton.instance();
            ck.register_for_clock_ticks(obj.src_to_dest_cbr_packets_generator);
            ck.register_for_clock_ticks(obj.dest_to_src_cbr_packets_generator);
        end
        
    end
    
end